/* wodd.t  WORK ORDER LINE DELETE TRIGGER                             */
/*Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                 */
/*All rights reserved worldwide.  This is an unpublished work.        */
/*V8:ConvertMode=NoConvert*/
/*********************************************************************/
/*  Program :wodd.t                                                  */
/*  Author  :Ben Holmes                                              */
/*  Date    :12/4/95                                                 */
/*  !Description : wod_det DELETE trigger program                    */
/*          : In order to enhance this trigger to support additional */
/*          : interfaces, add a DO-END block similar to the one      */
/*          : used for the Warehousing Interface to (1) check for the*/
/*          : need to continue processing; (2) move the relevant     */
/*          : fields to an appropriate work area; and (3) call       */
/*          : one or more subprograms to continue processing.        */
/*          : This .t program should remain short, relying on        */
/*          : subprograms to perform most of the work.               */
/*********************************************************************/
/*                             MODIFY LOG                            */
/*********************************************************************/
/*Revision 8.5          Last Modified:  12/04/95 BY: BHolmes *J0FY*  */
/*Revision 8.5          Last Modified:  06/12/96 BY: fwy     *J0KF*  */
/*Revision 8.5          Last Modified:  06/25/96 BY: BHolmes *J0M9*  */
/*Revision 8.5          Last Modified:  07/27/96 BY: fwy     *J12B*  */
/*Revision 8.5          Last Modified:  01/07/97 BY: jpm     *J1DM*  */
/*Revision 9.1          Last Modified:  08/12/00 BY: *N0KC* myb       */
/*                                                                   */
/*                                                                   */
/*********************************************************************/

TRIGGER PROCEDURE FOR DELETE OF WOD_DET.

/*J12B  if not can-find(first whl_mstr where whl_mstr.whl_act no-lock) */
/*J12B  then leave. */
/*J0KF  if wod_det.wod_qty_iss ge 0 and wod_det.wod_qty_req ge 0 */
/*J12B /*J0KF*/if wod_det.wod_qty_req ge 0 then leave. */
/*J12B  if abs(wod_det.wod_qty_iss) ge abs(wod_det.wod_qty_req) then leave. */

    {mfdeclre.i }
    define new shared variable w-recid as recid.
    define new shared work-table wf_old_wod_det like wod_det.
/*J0M9*/define new shared variable w-te_type as character.

    define variable w-file as character format "x(24)".


    /* Warehousing Interface processing */

    WI:
    do:

    /* If there is no active external warehouse that is flagged to
    receive work order export transactions, then do not process */
/*J12B*/    if not can-find(first whl_mstr no-lock
/*J12B*/        where whl_mstr.whl_act and whl_mstr.whl_wo_exp)
/*J12B*/    then leave WI.

    /* If the required quantity is positive, then do not process
    because the lad_det DELETE trigger processing will take care of it */
/*J12B*/    if wod_det.wod_qty_req ge 0 then leave WI.

    /* If at least as much material was issued/returned as required,
    then do not process because the external warehousing system will
    delete the line on its own without prompting from MFG/PRO */
/*J12B*/    if abs(wod_det.wod_qty_iss) ge abs(wod_det.wod_qty_req)
/*J12B*/    then leave WI.

    /* Move key wod_det values to work table for subsequent processing */
        assign w-recid = recid(wod_det).
        create wf_old_wod_det.
        if recid(wf_old_wod_det)= -1 then.
        assign
            wf_old_wod_det.wod_nbr       = wod_det.wod_nbr
            wf_old_wod_det.wod_lot       = wod_det.wod_lot
            wf_old_wod_det.wod_part      = wod_det.wod_part
            wf_old_wod_det.wod_op        = wod_det.wod_op
/*J0KF      wf_old_wod_det.wod_qty_all   = wod_det.wod_qty_all */
            wf_old_wod_det.wod_site      = wod_det.wod_site
            wf_old_wod_det.wod_loc       = wod_det.wod_loc
/*J0M9*/        wf_old_wod_det.wod_qty_req   = wod_det.wod_qty_req
            .
/*J0KF      if wod_det.wod_qty_req ge 0 then leave. */

    /* Call subprogram to create export transaction for warehouse */
        w-file = "wiwodd.p".
/*J1DM*/ /* {gprun.i ""wiwodd.p""} */
/*J1DM*/    {gprunmo.i &module="WI"
                       &program="wiwodd.p"}

/*J12B*/end. /* WI */
